<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>用户详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/web/res/css/xadmin.css">
    <script src="/web/res/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/web/res/js/xadmin.js"></script>
    <script type="text/javascript" src="/web/res/js/common.js"></script>
</head>
<body style="background-color: white;">
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <#if user?exists>
            <form class="layui-form layui-form-pane" id="formsubmit" style="margin:20px auto" action="/after/user/updateUser">
                <input type="hidden" id="id" name="id" value="${(user.id?c)!''}">
                <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">登录名：</label>
                    <div class="layui-input-block">
                        <input type="text"  style="width:80%;" readonly class="layui-input" value="${(user.loginname)!''}" />
                    </div>
                </div>
                <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">真实名称：</label>
                    <div class="layui-input-block">
                        <input type="text"  style="width:80%;" name="nick" class="layui-input" value="${(user.nick)!''}" />
                    </div>
                </div>
<!--                <div class="layui-form-item ">-->
<!--                    <label class="layui-form-label" style="width: 150px;  margin-right: 10px;">预览：</label>-->
<!--                    <div class="layui-input-block">-->
<!--                        <#if user?exists && user.pic?exists && user.pic?length gt 2>-->
<!--                        <div class="upload-imgBox" >-->
<!--                            <a href="javascript:void(0);" class="img_biges" title="${(user.pic)!''}">-->
<!--                                <input type="hidden"  id="imgpathhide"  value="${(user.pic)!''}"  class="layui-input"/>-->
<!--                                <img  src="${(user.pic)!''}" class="upload-select-img">-->
<!--                            </a>-->
<!--                        </div>-->
<!--                        <#else>-->
<!--                        <div class="divimg" style="margin-left:60px;" ><i class="layui-icon layui-icon-picture-fine"></i></div>-->
<!--                        </#if>-->
<!--                    </div>-->
<!--                </div>-->

                <div class="layui-form-item">
                    <div class="layui-upload">
                        <label class="layui-form-label lable-text-center" style="width: 150px;  margin-right: 10px;">头像：</label>
                        <div class="upload-list" id="uploadlist">
                            <div class="upload-imgBox">
                                <input type="hidden"  id="imgpathhide" value="${(user.pic)!''}"  class="layui-input"/>
                                <div class="upload-cancel">x</div>
                                <img  src="${(user.pic)!''}" class="upload-select-img">
                            </div>
                            <div class="upload-img" id="uploadtemplate" style="display:none;">+</div>
                        </div>
                    </div>
                </div>

<!--                <div class="layui-form-item ">-->
<!--                    <label class="layui-form-label" style="width: 150px;">手机号：</label>-->
<!--                    <div class="layui-input-block">-->
<!--                        <input type="text"  style="width:80%;" readonly class="layui-input" value="${(user.phone)!''}" />-->
<!--                    </div>-->
<!--                </div>-->
                <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">生日：</label>
                    <div class="layui-input-block">
                        <input type="text"  style="width:80%;" readonly  class="layui-input color-input"
                               value="<#if user.birthday?exists>${(user.birthday?string('yyyy-MM-dd HH:mm:ss'))!}</#if>" />
                    </div>
                </div>
                <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">地址：</label>
                    <div class="layui-input-block">
                        <input type="text"  style="width:80%;" readonly class="layui-input" value="${(user.address)!''}" />
                    </div>
                </div>
            <div class="layui-form-item ">
                <label class="layui-form-label" style="width: 150px;">我的签名：</label>
                <div class="layui-input-block">
                    <input type="text"  style="width:80%;" name="mysign" class="layui-input" value="${(user.mysign)!''}" />
                </div>
            </div>
            <div class="layui-form-item ">
                <label class="layui-form-label" style="width: 150px;">上级用户的邀请码：</label>
                <div class="layui-input-block">
                    <input type="text"   style="width:80%;"  name="invitationcode" class="layui-input" value="${(user.invitationcode)!''}" />
                </div>
            </div>
<!--            <div class="layui-form-item ">-->
<!--                <label class="layui-form-label" style="width: 150px;">邀请码：</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input type="text"  style="width:80%;" name="code"  class="layui-input" value="${(user.code)!''}" />-->
<!--                </div>-->
<!--            </div>-->

            <div class="layui-form-item">
                <label class="layui-form-label">门票</label>
                <div class="layui-input-block">
                    <select name="windowTicket" id="windowTicket" lay-filter="typeone" lay-verify="required"
                            style="margin: 0;">
                        <option value="1" <#if user?exists && user.windowTicket?exists><#if (user.windowTicket)?number == 1?number>selected</#if></#if>>购买</option>
                        <option value="2" <#if user?exists && user.windowTicket?exists><#if (user.windowTicket)?number == 2?number>selected</#if></#if>>未购买</option>
                    </select>
                </div>
                <label class="layui-form-label">是否禁用</label>
                <div class="layui-input-block">
                    <select name="states" id="states" lay-filter="typeone" lay-verify="required"
                            style="margin: 0;">
                        <option value="1" <#if user?exists && user.states?exists><#if (user.states)?number == 1?number>selected</#if></#if>>启用</option>
                        <option value="2" <#if user?exists && user.states?exists><#if (user.states)?number == 2?number>selected</#if></#if>>禁用</option>
                    </select>
                </div>
                <label class="layui-form-label">实名状态</label>
                <div class="layui-input-block">
                    <select name="status" id="status" lay-filter="typeone" lay-verify="required"
                            style="margin: 0;">
                        <option value="1" <#if user?exists && user.status?exists><#if (user.status)?number == 1?number>selected</#if></#if>>已实名</option>
                         <option value="2" <#if user?exists && user.status?exists><#if (user.status)?number == 2?number>selected</#if></#if>>未实名</option>
                    </select>
                </div>
            </div>


<!--            <div class="layui-form-item ">-->
<!--                <label class="layui-form-label" style="width: 150px;">推送唯一标识：</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input type="text"   style="width:80%;" readonly class="layui-input" value="${(user.token)!''}" />-->
<!--                </div>-->
<!--            </div>-->

            <div class="layui-form-item">
                <label class="layui-form-label">在线状态</label>
                <div class="layui-input-block">
                    <select name="onlinestatus" id="onlinestatus" lay-filter="typeone" lay-verify="required"
                            style="margin: 0;">
                        <option value="1" <#if user?exists && user.onlinestatus?exists><#if (user.onlinestatus)?number == 1?number>selected</#if></#if>>是</option>
                <option value="2" <#if user?exists && user.onlinestatus?exists><#if (user.onlinestatus)?number == 2?number>selected</#if></#if>>否</option>
                </select>
                </div>
                <label class="layui-form-label">青少年状态</label>
                <div class="layui-input-block">
                    <select name="teenagers" id="teenagers" lay-filter="typeone" lay-verify="required"
                            style="margin: 0;">
                        <option value="1" <#if user?exists && user.teenagers?exists><#if (user.teenagers)?number == 1?number>selected</#if></#if>>开启</option>
                        <option value="2" <#if user?exists && user.teenagers?exists><#if (user.teenagers)?number == 2?number>selected</#if></#if>>关闭</option>
                    </select>
                </div>
            </div>



            <div class="layui-form-item">
                <label class="layui-form-label">消息提示</label>
                <div class="layui-input-block">
                    <select name="messagealert" id="messagealert" lay-filter="typeone" lay-verify="required"
                            style="margin: 0;">
                        <option value="1" <#if user?exists && user.messagealert?exists><#if (user.messagealert)?number == 1?number>selected</#if></#if>>是</option>
                        <option value="2" <#if user?exists && user.messagealert?exists><#if (user.messagealert)?number == 2?number>selected</#if></#if>>否</option>
                     </select>
                </div>
                <label class="layui-form-label">仅接受好友消息</label>
                <div class="layui-input-block">
                    <select name="friendmessage" id="friendmessage" lay-filter="typeone" lay-verify="required"
                            style="margin: 0;">
                        <option value="1" <#if user?exists && user.friendmessage?exists><#if (user.friendmessage)?number == 1?number>selected</#if></#if>>开启</option>
                        <option value="2" <#if user?exists && user.friendmessage?exists><#if (user.friendmessage)?number == 2?number>selected</#if></#if>>关闭</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">附近功能</label>
                <div class="layui-input-block">
                    <select name="nearfunction" id="nearfunction" lay-filter="typeone" lay-verify="required"
                            style="margin: 0;">
                        <option value="1" <#if user?exists && user.nearfunction?exists><#if (user.nearfunction)?number == 1?number>selected</#if></#if>>是</option>
                        <option value="2" <#if user?exists && user.nearfunction?exists><#if (user.nearfunction)?number == 2?number>selected</#if></#if>>否</option>
                    </select>
                </div>
                <label class="layui-form-label" style=>是否有关联模块</label>
                <div class="layui-input-block">
                    <select name="modulestatus" id="modulestatus" lay-filter="typeone" lay-verify="required"
                            style="margin: 0;">
                        <option value="1" <#if user?exists && user.modulestatus?exists><#if (user.modulestatus)?number == 1?number>selected</#if></#if>>是</option>
                        <option value="2" <#if user?exists && user.modulestatus?exists><#if (user.modulestatus)?number == 2?number>selected</#if></#if>>否</option>
                </select>
                </div>
            </div>



<!--            <div class="layui-form-item ">-->
<!--                <label class="layui-form-label" style="width: 150px;">游戏消费钻石：</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input type="text"   style="width:80%;" readonly class="layui-input" value="${(user.gamemoney?c)!''}" />-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="layui-form-item">-->
<!--                <div class="layui-inline">-->
<!--                    <label class="layui-form-label" style="width: 150px;">音频直播：</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input type="checkbox" name="yinpinzb" value="${user.yinpinzb!''}" lay-skin="switch" lay-text="是|否" {{ user.yinpinzb != 1 ? 'checked' : '' }}  <#if user.yinpinzb?exists && (user.yinpinzb)?number == 1>checked</#if> disabled/>-->
<!--                    </div>-->
<!--                </div>-->
<!--                <div class="layui-inline">-->
<!--                    <label class="layui-form-label" style="width: 150px;">视频直播：</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input type="checkbox" name="states" value="${user.shipinzb!''}" lay-skin="switch" lay-text="是|否" {{ user.shipinzb != 1 ? 'checked' : '' }}  <#if user.shipinzb?exists && (user.shipinzb)?number == 1>checked</#if> disabled/>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 150px;">姓名：</label>
                    <div class="layui-input-inline">
                        <input type="text" readonly value="${(user.xingming)!''}" style=" width: 80%;" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 150px;">支付宝：</label>
                    <div class="layui-input-inline">
                        <input type="text" readonly value="${(user.alipay)!''}" style=" width: 80%;" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item ">
                <label class="layui-form-label" style="width: 150px;">银行卡号：</label>
                <div class="layui-input-block">
                    <input type="text"   style="width:80%;" readonly class="layui-input" value="${(user.banknum)!''}" />
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 150px;">动态总数：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="dongtaiall" value="${(user.dongtaiall)!''}" style=" width: 80%;" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 150px;">新增动态数：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="dongtai" value="${(user.dongtai)!''}" style=" width: 80%;" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item ">
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 150px;">新增粉丝数</label>
                    <div class="layui-input-inline">
                        <input type="text" name="fansnum" value="${(user.fansnum)!''}" style=" width: 80%;" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 150px;">粉丝总数：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="fansnumall" value="${(user.fansnumall)!''}" style=" width: 80%;" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 150px;">关注总数：</label>
                <div class="layui-input-block">
                    <input type="text" name="guanzhu" value="${(user.guanzhu)!''}" style=" width: 80%;" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item ">
                <label class="layui-form-label" style="width: 150px;">创建时间：</label>
                <div class="layui-input-block">
                    <input type="text"  style="width:80%;" readonly  class="layui-input color-input"
                           value="<#if user.createtime?exists>${(user.createtime?string('yyyy-MM-dd HH:mm:ss'))!}</#if>" />
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="button" class="layui-btn layui-btn-radius" lay-submit lay-filter="save" >&emsp;保存&emsp;</button>
                    <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" onclick="xadmin.close()">&emsp;返回&emsp;</button>
                </div>
            </div>
        </form>
        <#else>
        <div class="layui-form-item " style="text-align: center;">
            <h1>暂无记录</h1>
        </div>
        </#if>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['laydate', 'form', 'upload'], function () {
        let $ = layui.$;
        var form = layui.form;
        var upload = layui.upload;
        form.render();
        // 图片预览
        // $(".img_biges").click(function(){
        //     var url = $(this).attr('title');
        //     showimg(url)
        // });
        // 重新添加删除功能
        $('.upload-cancel').on('click', function(event){
            let self = $(event.currentTarget);
            self.parent().remove();
            event.stopPropagation();
        if ($("input[id='imgpathhide']").length < 1) {
            $('#uploadtemplate').show();
        } else {
            $('#uploadtemplate').hide();
        }
        });

        upload.render({
            elem: '#uploadtemplate',
            // auto: false,
            url: '/after/user/upOssImg',
            accept: 'images',
            acceptMime: 'images/*',
            choose: function (obj) {

            },
            done: function (res) {
                $('#uploadlist').prepend(
                    '<div class="upload-imgBox">  <input type="hidden"  id="imgpathhide" value="' + res.data.name + '"  class="layui-input"/><div class="upload-cancel">x</div><img  src="' + res.data.name + '" class="upload-select-img"></div>');
                $(".upload-cancel").on("click", function (e) {
                    $(this).parent().remove();
                    if ($("input[id='imgpathhide']").length < 1) {
                        $('#uploadtemplate').show();
                    }
                })
                if ($("input[id='imgpathhide']").length >= 1) {
                    $('#uploadtemplate').hide();
                }
            }
        });

        $.fn.extend({
            serializeObject: function () {
                var obj = {}; //声明一个对象
                $.each(this.serializeArray(), function (index, field) {
                    obj[field.name] = field.value; //通过变量，将属性值，属性一起放到对象中
                })
                return obj;
            }
        });
        form.on('submit(' + $("button[lay-submit]:eq(0)").attr("lay-filter") + ')', function (data) {

            console.log(data);
            $("input[id='imgpathhide']").each(function (index, ele) {
                $(this).attr("name", "pic");
            });
            layer.confirm('确认要保存吗？', function (index) {
                loading = layer.load(1);
                console.log(form.val("formsubmit"));
                ajaxPost($, $("#formsubmit").attr("action"), $("#formsubmit").serializeObject(), function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                            xadmin.father_reload();
                        });
                    } else {
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 2, time: 3000}, function () {

                        });
                    }
                });
            });
        });

    });


</script>
</html>
